#include <iostream>
#include <string>
using namespace std;

int n;
string str;

int main()
{
    cin >> str >> n;

    int begin = 0;
    double max_gcr = 0, GCC = 0;

    for (int l = 0, r = 0; r < str.size(); r++)
    {
        if (r - l + 1 > n)
        {
            if (str[l] == 'G' || str[l] == 'C')
                GCC--;
            l++;
        }

        if (str[r] == 'G' || str[r] == 'C')
            GCC++;

        double gcr = GCC / n;
        if (max_gcr < gcr)
        {
            max_gcr = gcr;
            begin = l;
        }
    }

    cout << str.substr(begin, n);

    return 0;
}
